﻿using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.DependencyInjection;
using Socket_Push_SDK;
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.AspNetCore.Builder
{
    public static class Socket_Push_Builder
    {
        public static string ReciveFuncName = "";
        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="T">ILinkAction的实现</typeparam>
        /// <param name="app"></param>
        /// <param name="HubPath">集线器路径</param>
        /// <param name="reciveFuncName">前端接收方法名</param>
        public static void UseSocket_Push<T>(this IApplicationBuilder app, string HubPath, string reciveFuncName= "recive") where T : ILinkAction, new()
        {
            ReciveFuncName = reciveFuncName;
            app.UseCors("SignalR");
            app.UseSignalR(p =>
            {
                p.MapHub<LinkHub<T>>(new PathString(HubPath));
            });
        }
        public static void AddSocket_Push(this IServiceCollection services)
        {
            services.AddSignalR();
        }
    }
}
